package LeetCodeP;

public class Souluction709 {
    public static  String toLowerCase2(String str) {
        char[] st = new char[str.length()];
        char c;
        for (int i = 0; i < str.length(); i++) {
            c = str.charAt(i);
            if (c >= 65 && c <= 90) {
                c = (char) (c + 32);
            }
            st[i] = c;
        }
        return new String(st);


    }

    public static String toLowerCase1(String str){
        char[] chars = new char[str.length()];
        char c;
        for (int i=0;i<chars.length;i++){
            c=str.charAt(i);
            if (c>=65&&c<=90){
                c=(char)(c+32);
            }
            chars[i]=c;
            System.out.println(chars[i]);
        }
        return new String(chars);
    }

    public static  String toLowerCase(String str) {
        char[] strChar = new char[str.length()];
        char c;
        for (int i = 0; i < strChar.length; i++) {
            c = str.charAt(i);
            if (c>=65&&c<=90){
                c=(char)(c+32);
            }
            strChar[i]=c;
            System.out.println(strChar[i]);
        }

        return new String(strChar);

    }
    /**
     * 将二进制转换成字符
     * @param binStr 二进制字符串
     * @return char
     * @Auth zongf
     * @Date 2019-05-07
     */
    private static char binstrToChar(String binStr){
        int[] temp=binstrToIntArray(binStr);
        int sum=0;
        for(int i=0; i<temp.length;i++){
            sum +=temp[temp.length-1-i]<<i;
        }
        return (char)sum;
    }

    /**
     * 二进制字符转换为int数组
     * @param binStr 二进制字符串
     * @return int[]
     * @Auth zongf
     * @Date 2019-05-07
     */
    private static int[] binstrToIntArray(String binStr) {
        char[] temp=binStr.toCharArray();
        int[] result=new int[temp.length];
        for(int i=0;i<temp.length;i++) {
            result[i]=temp[i]-48;
        }
        return result;
    }

    public static void main(String[] args) {
        String s="ABCDEF";
        String S1="A";

        toLowerCase(s);
    }
}
